<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <base href="<%=basePath%>"/>
    <title>茶叶商城 - 茶叶进销存系统</title>
    <link rel="stylesheet" href="css/global.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrap.min.css" />
    <link rel="stylesheet" href="<%=basePath%>css/simple-line-icons.css" />
    <link rel="stylesheet" href="<%=basePath%>css/icofont.css" />
    <link rel="stylesheet" href="<%=basePath%>css/magnific-popup.css" />
    <link rel="stylesheet" href="<%=basePath%>css/animate.css" />
    <link rel="stylesheet" href="<%=basePath%>css/nice-select.css" />
    <link rel="stylesheet" href="<%=basePath%>css/jquery-ui.css" />
    <link rel="stylesheet" href="<%=basePath%>css/owl.carousel.min.css" />
    <link rel="stylesheet" href="<%=basePath%>css/mainmenu.css" />
    <!-- Style CSS Hear -->
    <link rel="stylesheet" href="<%=basePath%>css/style.css" />
    <link rel="stylesheet" href="<%=basePath%>css/responsive.css" />
    <script src="<%=basePath%>js/vendor/modernizr-2.8.3.min.js"></script>
    <style>
        .shop-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
            background: #f8f9fa;
            min-height: 100vh;
        }
        
        .shop-header {
            background: linear-gradient(135deg, var(--primary-color), #7a8d5d);
            color: white;
            padding: 40px 0;
            text-align: center;
            margin-bottom: 30px;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(139, 158, 107, 0.3);
        }
        
        .shop-header h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
            font-weight: 600;
        }
        
        .shop-header p {
            font-size: 1.1rem;
            opacity: 0.9;
            margin: 0;
        }
        
        .shop-content {
            display: grid;
            grid-template-columns: 280px 1fr;
            gap: 30px;
            margin-bottom: 30px;
        }
        
        .shop-sidebar {
            background: white;
            border-radius: 12px;
            padding: 25px;
            box-shadow: 0 2px 15px rgba(0,0,0,0.08);
            height: fit-content;
            position: sticky;
            top: 20px;
        }
        
        .sidebar-section {
            margin-bottom: 30px;
        }
        
        .sidebar-section:last-child {
            margin-bottom: 0;
        }
        
        .sidebar-title {
            font-size: 1.2rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--primary-color);
            display: flex;
            align-items: center;
        }
        
        .sidebar-title i {
            margin-right: 8px;
            color: var(--primary-color);
        }
        
        .category-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        
        .category-list li {
            margin-bottom: 8px;
        }
        
        .category-list a {
            display: block;
            padding: 10px 15px;
            color: var(--text-regular);
            text-decoration: none;
            border-radius: 8px;
            transition: all 0.3s;
            border: 1px solid transparent;
        }
        
        .category-list a:hover,
        .category-list a.active {
            background: var(--primary-color);
            color: white;
            transform: translateX(5px);
        }
        
        .search-box {
            position: relative;
        }
        
        .search-box input {
            width: 100%;
            padding: 12px 45px 12px 15px;
            border: 2px solid #e1e5e9;
            border-radius: 8px;
            font-size: 14px;
            transition: border-color 0.3s;
        }
        
        .search-box input:focus {
            outline: none;
            border-color: var(--primary-color);
        }
        
        .search-box button {
            position: absolute;
            right: 5px;
            top: 50%;
            transform: translateY(-50%);
            background: var(--primary-color);
            border: none;
            color: white;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.3s;
        }
        
        .search-box button:hover {
            background: #7a8d5d;
        }
        
        .products-area {
            background: white;
            border-radius: 12px;
            padding: 25px;
            box-shadow: 0 2px 15px rgba(0,0,0,0.08);
        }
        
        .products-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid #e1e5e9;
        }
        
        .products-count {
            color: var(--text-secondary);
            font-size: 14px;
        }
        
        .sort-select {
            padding: 8px 15px;
            border: 1px solid #e1e5e9;
            border-radius: 6px;
            background: white;
            color: var(--text-regular);
            cursor: pointer;
        }
        
        .products-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 25px;
            margin-bottom: 30px;
        }
        
        .product-card {
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0,0,0,0.08);
            transition: all 0.3s;
            border: 1px solid #f0f0f0;
        }
        
        .product-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(139, 158, 107, 0.2);
        }
        
        .product-image {
            position: relative;
            height: 220px;
            overflow: hidden;
        }
        
        .product-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s;
        }
        
        .product-card:hover .product-image img {
            transform: scale(1.05);
        }
        
        .product-actions {
            position: absolute;
            top: 15px;
            right: 15px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            opacity: 0;
            transition: opacity 0.3s;
        }
        
        .product-card:hover .product-actions {
            opacity: 1;
        }
        
        .action-btn {
            width: 40px;
            height: 40px;
            background: white;
            border: none;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary-color);
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            text-decoration: none;
        }
        
        .action-btn:hover {
            background: var(--primary-color);
            color: white;
            transform: scale(1.1);
        }
        
        .product-info {
            padding: 20px;
        }
        
        .product-name {
            font-size: 1.1rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 8px;
            line-height: 1.4;
        }
        
        .product-name a {
            color: inherit;
            text-decoration: none;
            transition: color 0.3s;
        }
        
        .product-name a:hover {
            color: var(--primary-color);
        }
        
        .product-price {
            font-size: 1.3rem;
            font-weight: 700;
            color: var(--primary-color);
            margin-bottom: 15px;
        }
        
        .add-to-cart-btn {
            width: 100%;
            padding: 12px;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 8px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        
        .add-to-cart-btn:hover {
            background: #7a8d5d;
            transform: translateY(-2px);
        }
        
        .tea-icon {
            color: var(--primary-color);
            margin-right: 5px;
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: var(--text-secondary);
        }

        .empty-state i {
            font-size: 4rem;
            margin-bottom: 20px;
            opacity: 0.5;
        }

        .empty-state h3 {
            margin-bottom: 10px;
            color: var(--text-primary);
        }

        .pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin-top: 30px;
        }

        .pagination a {
            padding: 10px 15px;
            background: white;
            color: var(--text-regular);
            text-decoration: none;
            border-radius: 8px;
            border: 1px solid #e1e5e9;
            transition: all 0.3s;
        }

        .pagination a:hover,
        .pagination a.active {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }

        @media (max-width: 768px) {
            .shop-content {
                grid-template-columns: 1fr;
                gap: 20px;
            }

            .shop-sidebar {
                position: static;
            }

            .products-grid {
                grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
                gap: 20px;
            }

            .products-header {
                flex-direction: column;
                gap: 15px;
                align-items: stretch;
            }
        }
    </style>
</head>
<body>
<div class="shop-container">
    <header>
        <div class="header-area bg-gray">
            <div class="container">
                <div class="row">
                    <div class="col-lg-3 col-md-4">
                        <div class="logo">
                            <a href="<%=basePath%>views/user/index.jsp"
                            ><img src="<%=basePath%>images/img/logo/logo.png" alt=""
                            /></a>
                        </div>
                    </div>
                    <div class="col-lg-9 col-md-8">
                        <div class="header-main-content">
                            <div class="main-menu-area d-none d-lg-block">
                                <nav>
                                    <ul>
                                        <li>
                                            <a href="<%=basePath%>views/user/index.jsp"
                                            >首页
                                                <%--                            <i class="icofont icofont-simple-down"></i>--%>
                                            </a>
                                            <%--
                                            <ul class="sub-menu">
                                              --%> <%--
                            <li><a href="home-box.html">首页盒</a></li>
                            --%> <%--
                          </ul>
                          --%>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/about-us.jsp"
                                            >关于我们</a
                                            >
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>user/shop"
                                            >商城 <i class="icofont icofont-simple-down"></i
                                            ></a>
                                            <ul class="sub-menu">
                                                <%--
                                                <li><a href="shop-right.html">正确选购</a></li>
                                                --%>
                                                <li>
                                                    <a href="<%=basePath%>user/cart"
                                                    >购物车</a
                                                    >
                                                </li>
                                                <li>
                                                    <a href="<%=basePath%>user/orders"
                                                    >订单</a
                                                    >
                                                </li>
                                                <%--
                                                <li>
                                                  <a href="<%=basePath%>views/user/wishlist.jsp"
                                                    >愿望清单</a
                                                  >
                                                </li>
                                                --%>
                                            </ul>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/shop.jsp">
                                                我的 <i class="icofont icofont-simple-down"></i
                                            ></a>
                                            <ul class="sub-menu">
                                                <li>
                                                    <a href="<%=basePath%>views/user/my-account.jsp"
                                                    >我的账户</a
                                                    >
                                                </li>
                                                <%--
                                                <li>
                                                  <a
                                                    href="<%=basePath%>views/user/single-product.jsp"
                                                    >单品</a
                                                  >
                                                </li>
                                                --%> <%--
                            <li>
                              <a href="<%=basePath%>views/user/blog-details.jsp"
                                >博客详情</a
                              >
                            </li>
                            --%>
                                                <li>
                                                    <a href="<%=basePath%>views/login.jsp"
                                                    >登录注册</a
                                                    >
                                                </li>
                                            </ul>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/blog.jsp">博客</a>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/contact-us.jsp">
                                                联系我们</a
                                            >
                                        </li>
                                    </ul>
                                </nav>
                            </div>
                            <div class="right-blok-box">
                                <div class="serch-container hidden-xs">
                                    <a href="#"><i class="icon-magnifier"></i></a>
                                    <div class="blog-search">
                                        <form action="#" id="search">
                                            <input
                                                    type="text"
                                                    placeholder="点击此处进行搜索"
                                                    name="s"
                                            />
                                            <button type="submit">
                                                <i class="icofont icofont-search-alt-1"></i>
                                            </button>
                                        </form>
                                    </div>
                                </div>
                                <div class="mine-cart-box">
                                    <a href="<%=basePath%>user/cart"
                                    ><i class="icon-handbag"></i
                                    ><span id="cart-total">2</span></a
                                    >
                                    <ul class="mini-cart">
                                        <li class="cart-item">
                                            <div class="cart-image">
                                                <a href="<%=basePath%>views/user/single-product.jsp"
                                                ><img
                                                        src="<%=basePath%>images/img/product/1.jpg"
                                                        alt=""
                                                /></a>
                                            </div>
                                            <div class="cart-title">
                                                <a href="<%=basePath%>views/user/single-product.jsp"
                                                ><h4>热茶</h4></a
                                                >
                                                <span class="quantity">1 ×</span>
                                                <div class="price-box">
                                                    <span class="new-price">$ 130.00</span>
                                                </div>
                                                <a href="#" class="remove_from_cart"
                                                ><i class="icon-trash icons"></i
                                                ></a>
                                            </div>
                                        </li>
                                        <li class="cart-item">
                                            <div class="cart-image">
                                                <a href="<%=basePath%>views/user/single-product.jsp"
                                                ><img
                                                        src="<%=basePath%>images/img/product/6.jpg"
                                                        alt=""
                                                /></a>
                                            </div>
                                            <div class="cart-title">
                                                <a href="<%=basePath%>views/user/single-product.jsp"
                                                ><h4>水果绿茶</h4></a
                                                >
                                                <span class="quantity">1 ×</span>
                                                <div class="price-box">
                                                    <span class="new-price">$ 100.99</span>
                                                </div>
                                                <a href="#" class="remove_from_cart"
                                                ><i class="icon-trash icons"></i
                                                ></a>
                                            </div>
                                        </li>
                                        <li class="subtotal-titles">
                                            <div class="subtotal-titles">
                                                <h3>总价 :</h3>
                                                <span>$ 230.99</span>
                                            </div>
                                        </li>
                                        <li class="mini-cart-btns">
                                            <div class="cart-btns">
                                                <a href="<%=basePath%>user/cart"
                                                >购物车</a
                                                >
                                                <a href="<%=basePath%>user/orders">订单</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="top-login-menu">
                                    <div class="top-login-inner">
                                        <c:choose>
                                            <c:when test="${not empty sessionScope.customerName}">
                                                <a href="<%=basePath%>views/user/my-account.jsp"
                                                ><i class="icon-user"></i>
                                                    <span class="user-login"
                                                    >${sessionScope.customerName}</span
                                                    >
                                                </a>
                                            </c:when>
                                            <c:otherwise>
                                                <a href="<%=basePath%>views/login.jsp"
                                                ><i class="icon-user"></i>
                                                    <span class="user-login">Login</span>
                                                </a>
                                            </c:otherwise>
                                        </c:choose>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <!-- Mobile Menu Area Start -->
                        <div class="mobile-menu-area d-block d-lg-none">
                            <div class="mobile-menu">
                                <nav id="mobile-menu-active">
                                    <ul>
                                        <li>
                                            <a href="<%=basePath%>views/user/index.jsp">首页</a>
                                            <%--
                                            <ul>
                                              --%> <%--
                            <li><a href="home-box.html">首页盒</a></li>
                            --%> <%--
                          </ul>
                          --%>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/about-us.jsp"
                                            >关于我们</a
                                            >
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/shop.jsp">商城</a>
                                            <ul>
                                                <li><a href="shop-right.html">Shop Right</a></li>
                                                <li>
                                                    <a href="<%=basePath%>views/user/checkout.jsp"
                                                    >Checkout</a
                                                    >
                                                </li>
                                                <li>
                                                    <a href="<%=basePath%>views/user/wishlist.jsp"
                                                    >Wish List</a
                                                    >
                                                </li>
                                                <li>
                                                    <a href="<%=basePath%>views/user/cart.jsp"
                                                    >Cart</a
                                                    >
                                                </li>
                                            </ul>
                                        </li>
                                        <li>
                                            <a href="#"> Pages</a>
                                            <ul>
                                                <li>
                                                    <a href="<%=basePath%>views/user/my-account.jsp"
                                                    >My account</a
                                                    >
                                                </li>
                                                <li>
                                                    <a
                                                            href="<%=basePath%>views/user/single-product.jsp"
                                                    >Single Product</a
                                                    >
                                                </li>
                                                <li>
                                                    <a href="<%=basePath%>views/user/blog-details.jsp"
                                                    >Blog details</a
                                                    >
                                                </li>
                                                <li>
                                                    <a href="<%=basePath%>views/login.jsp"
                                                    >Login Register</a
                                                    >
                                                </li>
                                            </ul>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/blog.jsp">Blog</a>
                                        </li>
                                        <li>
                                            <a href="<%=basePath%>views/user/contact-us.jsp">
                                                Contact Us</a
                                            >
                                        </li>
                                    </ul>
                                </nav>
                            </div>
                        </div>
                        <!-- Mobile Menu Area End -->
                    </div>
                </div>
            </div>
        </div>
    </header>
    <!-- 商城头部 -->
    <div class="shop-header">

        <h1><i class="fas fa-store tea-icon"></i> 茶叶商城</h1>
        <p>精选优质茶叶，品味自然香醇</p>
    </div>

    <!-- 商城内容 -->
    <div class="shop-content">
        <!-- 侧边栏 -->
        <div class="shop-sidebar">
            <!-- 分类筛选 -->
            <div class="sidebar-section">
                <h3 class="sidebar-title">
                    <i class="fas fa-list"></i> 茶叶分类
                </h3>
                <ul class="category-list">
                    <li>
                        <a href="<%=basePath%>user/shop" class="${empty selectedCategory ? 'active' : ''}">
                            <i class="fas fa-th-large"></i> 全部分类
                        </a>
                    </li>
                    <c:forEach items="${categories}" var="category">
                        <li>
                            <a href="<%=basePath%>user/shop?category=${category.category_id}"
                               class="${selectedCategory eq category.category_id ? 'active' : ''}">
                                <i class="fas fa-leaf"></i> ${category.category_name}
                            </a>
                        </li>
                    </c:forEach>
                </ul>
            </div>

            <!-- 搜索功能 -->
            <div class="sidebar-section">
                <h3 class="sidebar-title">
                    <i class="fas fa-search"></i> 商品搜索
                </h3>
                <form action="<%=basePath%>user/shop" method="get" class="search-box">
                    <input type="text" name="search" placeholder="输入茶叶名称..." value="${searchKeyword}">
                    <c:if test="${not empty selectedCategory}">
                        <input type="hidden" name="category" value="${selectedCategory}">
                    </c:if>
                    <button type="submit">
                        <i class="fas fa-search"></i>
                    </button>
                </form>
            </div>
        </div>

        <!-- 商品展示区域 -->
        <div class="products-area">
            <!-- 商品头部信息 -->
            <div class="products-header">
                <div class="products-count">
                    <i class="fas fa-info-circle tea-icon"></i>
                    显示 ${(currentPage-1)*12+1}-${currentPage*12 > totalRecords ? totalRecords : currentPage*12} 共 ${totalRecords} 个结果
                </div>
                <div class="sort-section">
                    <select id="sortSelect" class="sort-select" onchange="sortProducts()">
                        <option value="default">默认排序</option>
                        <option value="price_asc">价格从低到高</option>
                        <option value="price_desc">价格从高到低</option>
                        <option value="name_asc">名称A-Z</option>
                        <option value="name_desc">名称Z-A</option>
                    </select>
                </div>
            </div>

            <!-- 商品网格 -->
            <div class="products-grid" id="products-grid">
                <c:choose>
                    <c:when test="${not empty teaList}">
                        <c:forEach items="${teaList}" var="tea">
                            <div class="product-card">
                                <div class="product-image">
                                    <a href="<%=basePath%>user/product?id=${tea.tea_id}">
                                        <img src="<%=basePath%>images/img/product/${tea.image != null ? tea.image : '1.jpg'}" alt="${tea.tea_name}">
                                    </a>
                                    <div class="product-actions">
                                        <button class="action-btn" onclick="addToCart(${tea.tea_id})" title="添加到购物车">
                                            <i class="fas fa-shopping-cart"></i>
                                        </button>
                                        <a href="<%=basePath%>user/product?id=${tea.tea_id}" class="action-btn" title="查看详情">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                    </div>
                                </div>
                                <div class="product-info">
                                    <h3 class="product-name">
                                        <a href="<%=basePath%>user/product?id=${tea.tea_id}">${tea.tea_name}</a>
                                    </h3>
                                    <div class="product-price">
                                        ¥<fmt:formatNumber value="${tea.price}" pattern="#,##0.00"/>/${tea.unit}
                                    </div>
                                    <button class="add-to-cart-btn" onclick="addToCart(${tea.tea_id})">
                                        <i class="fas fa-cart-plus"></i>
                                        加入购物车
                                    </button>
                                </div>
                            </div>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                        <div class="empty-state">
                            <i class="fas fa-search"></i>
                            <h3>暂无商品</h3>
                            <p>没有找到符合条件的茶叶商品，请尝试其他搜索条件</p>
                        </div>
                    </c:otherwise>
                </c:choose>
            </div>

            <!-- 分页导航 -->
            <c:if test="${totalPages > 1}">
                <div class="pagination">
                    <c:if test="${currentPage > 1}">
                        <a href="<%=basePath%>user/shop?page=${currentPage-1}&category=${selectedCategory}&search=${searchKeyword}">
                            <i class="fas fa-chevron-left"></i> 上一页
                        </a>
                    </c:if>

                    <c:forEach begin="1" end="${totalPages}" var="i">
                        <a href="<%=basePath%>user/shop?page=${i}&category=${selectedCategory}&search=${searchKeyword}"
                           class="${i == currentPage ? 'active' : ''}">${i}</a>
                    </c:forEach>

                    <c:if test="${currentPage < totalPages}">
                        <a href="<%=basePath%>user/shop?page=${currentPage+1}&category=${selectedCategory}&search=${searchKeyword}">
                            下一页 <i class="fas fa-chevron-right"></i>
                        </a>
                    </c:if>
                </div>
            </c:if>
        </div>
    </div>
</div>

<script>
// 添加到购物车
function addToCart(teaId) {
    // 检查是否登录
    var isLoggedIn = '${sessionScope.customerId}' !== '';

    if (!isLoggedIn) {
        alert('请先登录');
        window.location.href = '<%=basePath%>views/login.jsp';
        return;
    }

    var quantity = prompt('请输入购买数量:', '1');
    if (quantity && quantity > 0) {
        // 发送AJAX请求添加到购物车
        fetch('<%=basePath%>user/addToCart', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: 'teaId=' + teaId + '&quantity=' + quantity
        })
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                alert('添加成功！');
                updateCartCount();
            } else {
                alert(data.message || '添加失败');
            }
        })
        .catch(error => {
            console.error('Error:', error);
            alert('网络错误，请重试');
        });
    }
}

// 更新购物车数量
function updateCartCount() {
    // 这里可以通过AJAX获取购物车商品数量
    // 暂时简单处理
    console.log('购物车数量已更新');
}

// 排序功能
function sortProducts() {
    var sortValue = document.getElementById('sortSelect').value;
    var currentUrl = new URL(window.location.href);
    currentUrl.searchParams.set('sort', sortValue);
    window.location.href = currentUrl.toString();
}

// 页面加载完成后的初始化
document.addEventListener('DOMContentLoaded', function() {
    // 初始化购物车数量
    updateCartCount();

    // 设置排序选择器的当前值
    var urlParams = new URLSearchParams(window.location.search);
    var sortValue = urlParams.get('sort');
    if (sortValue) {
        document.getElementById('sortSelect').value = sortValue;
    }
});
</script>

</body>
</html>
